//
//  YMVideoPlayer.h
//  VideoPlay
//
//  Created by apple on 16/3/22.
//  Copyright © 2016年 apple. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@class YMVideoPlayer;


typedef NS_ENUM(NSInteger,YMVideoPlayerPlayState) {
    YMVideoPlayerPlayStatePlaying,
    YMVideoPlayerPlayStateStop,
};

typedef NS_ENUM(NSInteger,YMVideoPlayerDisplayMode) {
    YMVideoPlayerDisplayModeAspectFit,
    YMVideoPlayerDisplayModeAspectFill
};

@protocol YMVideoPlayerDelegate <NSObject>

@optional

- (void)videoPlayerDidReadyPlay:(YMVideoPlayer *)videoPlayer;

- (void)videoPlayerDidBeginPlay:(YMVideoPlayer *)videoPlayer;

- (void)videoPlayerDidEndPlay:(YMVideoPlayer *)videoPlayer;

- (void)videoPlayerDidSwitchPlay:(YMVideoPlayer *)videoPlayer;

- (void)videoPlayerDidFailedPlay:(YMVideoPlayer *)videoPlayer;

@end


@interface YMVideoPlayer : NSObject

@property (nonatomic,  weak) id <YMVideoPlayerDelegate> delegate;

@property (nonatomic,  copy) void (^progressBlock)(float progress);

@property (nonatomic,  copy) void (^bufferProgressBlock)(float progress);

@property (nonatomic,  copy) void (^currentTimeBlock)(float progress);

@property (nonatomic,  copy) void (^maxTimeBlock)(float progress);

@property (nonatomic,assign,readonly) YMVideoPlayerPlayState playState;

@property (nonatomic,  copy) NSString *path; //Support both local and remote resource.

@property (nonatomic,assign) BOOL pausePlayWhenMove; //Default YES.

@property (nonatomic,assign) YMVideoPlayerDisplayMode displayMode;

- (void)playInContainer:(UIView *)container;

- (void)play;

- (void)playAtTheBeginning;

- (void)moveTo:(float)to; //0 to 1.

- (void)pause;

- (void)clear;

+ (instancetype)createAVPlayer;


@end
